const Generator = require('yeoman-generator');

module.exports = class extends Generator {
    prompting() {
        return this.prompt([
            {
                type: 'input',
                name: 'name',
                message: 'your project name?',
                default: 'my-project'
            }
        ])
        .then(answer => {
            this.answers = this.answers || {};
            this.answers.name = answer.name;
            console.log(this.answers)
        })
    }

    writing() {
        const templates = [
            'vite.config.ts',
            'tsconfig.json',
            'README.md',
            'README.en.md',
            'package.json',
            'index.html',
            '.gitignore',
            '.eslintrc.json',
            'src/vite-env.d.ts',
            'src/shims-vue.d.ts',
            'src/router.ts',
            'src/main.ts',
            'src/elementui.ts',
            'src/common.less',
            'src/App.vue',
            'src/app.less',
            'src/utils/index.ts',
            'src/utils/http.ts',
            'src/utils/errorcode.ts',
            'src/utils/auth.ts',
            'src/store/index.ts',
            'src/store/modules/user.ts',
            'src/pages/helloworld/index.vue',
            'src/pages/helloworld/index.less',
            'src/pages/home/index.vue',
            'src/pages/login/index.vue',
            'src/pages/production/list/index.vue',
            'src/pages/production/upload/index.vue',
            'src/pages/system/user/index.vue',
            'src/i18n/en.ts',
            'src/i18n/zh.ts',
            'src/i18n/index.ts',
            'src/envconfig/development.json',
            'src/envconfig/production.json',
            'src/envconfig/index.ts',
            'src/components/sidenav/index.vue',
            'src/api/goods/goods.ts',
            'src/api/goods/index.ts',
            'src/api/system/user.ts',
            'src/api/goods/index.ts',
            'src/api/index.ts',
        ];

        templates.forEach(src => {
            this.fs.copyTpl(
                this.templatePath(src),
                this.destinationPath(src),
                this.answers
            )
        })
    }
}